package com.example.deadletter.provider;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author tianzhuang
 * @version 1.0
 * @date 2021/11/10 18:29
 */
@Component
public class provider {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Bean
    public void sendMessage() {
        String msg = "this is a message"+ new Date();
        System.err.println("发送消息"+msg);
        rabbitTemplate.convertAndSend("testexchange4","", msg);
    }
}
